/**
 @File    :   index.js.js
 @Contact :
 @Author  :     ypy

 @Modify Time      @Author    @Version    @Desciption
 ------------      -------    --------    -----------
 2021/2/24 11:10   ypy      1.0         None
 */

//刷新所有开奖
function refresh_all_history_data() {
    $.ajax({
        url: "./",
        type: "GET",
        data: {cmd_class: "query", command: "refresh_all_history_data",},
        success: function (callback) {
            alert('已更新最新开奖信息');
        },
        error: function () {
            alert('更新失败');
        }
    })
}


//下载excel数据备份,TODO:还未做身份识别
function download_excel() {
    $.ajax({
        url: "./",
        type: "GET",
        data: {cmd_class: "query", command: "download_excel",},
        success: function (callback) {
            window.open(callback);
            // alert('导出完成');
        },
        error: function () {
            alert('导出失败');
        }
    })
}


//
function SelectFile() {
    var promise = $.Deferred();
    var input = $("<input type='file'/>");
    ischrome = window.navigator.userAgent.indexOf("Chrome") > -1;
    if (ischrome) {
        //chrome是使用的非阻塞 选择文件是不会中断主线程的js执行的

        input.change(function () {
            promise.resolve(this.files);
        });
        input.click();
    } else {
        //ie firefox是阻塞的 选择文件会中断主线程的js执行
        input.click();
        var files = input[0].files;
        if (files.length > 0) {
            promise.resolve(files);
        }
    }
    return promise;
}


//上传文件，TODO:还未做身份识别
function upload_excel(){
    var selectfile = SelectFile();
    alert(selectfile);
}